/**
 * \file
 *
 *  \brief Created on: Apr 14, 2011
 *   @author: calle
 */


/**
 * \class IContextDecorator IContextDecorator.h <Generator/context/IContextDecorator.h>
 *
 * \brief Implementation of context decorator class
 *
 *
 * \ingroup Context
 *
 */
#ifndef ICONTEXTDECORATOR_H_
#define ICONTEXTDECORATOR_H_

#include <Generator/context/IContext.h>

class IContextDecorator: public IContext {

public:
	IContextDecorator(IContext* contex);

	virtual ~IContextDecorator();

	/**
	 * \brief check whether an identification exists
	 *
	 * when about to add a new variable its crucial that it be checked by
	 * the context, this check will do a validation if the identification exists.
	 * In case the ident exists this method will return true.
	 *
	 * @param ident
	 * @return true if identification variable is ok
	 */
	virtual bool identExists(const Ident& ident) const;
	/**
	 * \brief adds an new variable to the specific context.
	 *
	 * Adds a new variable identification of a certain type to the context.
	 * In case of success true is returned otherwise false. Most obvious
	 * reason for not adding a variable is the clashing instance of the same name.
	 *
	 * @param type
	 * @param ident
	 * @return true on success otherwise false
	 */
	virtual bool addIdent(TypeEnum type, const Ident& ident);
	/**
	 * \brief remove a variable identification from the context.
	 *
	 * Remove the identification variable from the context.
	 *
	 * @param ident
	 * @return
	 */
	virtual bool removeIdent(const Ident& ident);

	/**
	 * \brief finds the type for an identification
	 *
	 * Returns the type for an variable identification.
	 * in case the identification don't exist NULL is returned.
	 * Since the return type is a clone, it is up to the caller
	 * to release returned type.
	 *
	 *
	 * @param ident
	 * @return Type of identification
	 */
	virtual bool findType(const Ident& ident,TypeEnum& type)const;

	/**
	 * \brief returns the parent context.
	 *
	 * This will return the parent context.
	 *
	 * @return parent context
	 */
	virtual IContext* getParent() const;

	/**
	 * \brief Implementation of getAllOfType from IContext.
	 *
	 * Checks all occurrences of type in the Context.
	 *
	 * @see IContext
	 *
	 * @param type to be checked
	 * @param list with matching idents.
	 */

	virtual void getAllOfType(TypeEnum type, IContext::TypeList& list) const;

protected:
	IContext *m_context;

};

#endif /* CONTEXTDECORATOR_H_ */
